package com.ruoyi.project.rgv.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.rgv.domain.MsgRgv;
import com.ruoyi.project.rgv.service.IMsgRgvService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备监控RGVController
 * 
 * @author ruoyi
 * @date 2023-04-11
 */
@Controller
@RequestMapping("/project/rgv")
public class MsgRgvController extends BaseController
{
    private String prefix = "project/rgv";

    @Autowired
    private IMsgRgvService msgRgvService;

    @GetMapping()
    public String rgv()
    {
        return prefix + "/rgv";
    }

    /**
     * 查询设备监控RGV列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MsgRgv msgRgv)
    {
        startPage();
        List<MsgRgv> list = msgRgvService.selectMsgRgvList(msgRgv);
        return getDataTable(list);
    }

    /**
     * 导出设备监控RGV列表
     */
    @Log(title = "设备监控RGV", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MsgRgv msgRgv)
    {
        List<MsgRgv> list = msgRgvService.selectMsgRgvList(msgRgv);
        ExcelUtil<MsgRgv> util = new ExcelUtil<MsgRgv>(MsgRgv.class);
        return util.exportExcel(list, "设备监控RGV数据");
    }

    /**
     * 新增设备监控RGV
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存设备监控RGV
     */
    @Log(title = "设备监控RGV", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MsgRgv msgRgv)
    {
        return toAjax(msgRgvService.insertMsgRgv(msgRgv));
    }

    /**
     * 修改设备监控RGV
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MsgRgv msgRgv = msgRgvService.selectMsgRgvById(id);
        mmap.put("msgRgv", msgRgv);
        return prefix + "/edit";
    }

    /**
     * 修改保存设备监控RGV
     */
    @Log(title = "设备监控RGV", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MsgRgv msgRgv)
    {
        return toAjax(msgRgvService.updateMsgRgv(msgRgv));
    }

    /**
     * 删除设备监控RGV
     */
    @Log(title = "设备监控RGV", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(msgRgvService.deleteMsgRgvByIds(ids));
    }
}
